Add httpMaxRetryCount && Simplify http fallback flow#80
Add httpMaxRetryCount && Simplify http fallback flow#80mattheworiordan merged 1 commit intoably:masterfrom
Conversation
|
Test cases for that will require utilising |
There was a problem hiding this comment.
If this is private we don't necessarily need a javadoc comment, but please either add a comment or remove the TODO. It's not worth leaving like this.
|
I like this, but please see the comments above. |
7ab0be6 to
8b59f05
Compare
There was a problem hiding this comment.
Am I missing something here, as far as I can tell we have removed the fallback host functionality fro Realtime connections in this commit? The Random class is not even used anymore, and the connection implementation still references fallback hosts yet does not use them, see https://github.com/gokhanbarisaker/ably-java/blob/8b59f05590e123462f2603ffccdd9a696f4e0434/lib/src/main/java/io/ably/lib/transport/ConnectionManager.java#L574-L578
The previous functionality wasn't reverting to the last successful host for an HTTP request. It was saying that if this is a realtime instance, and it is currently connected, then that host is the preferred host. |
The |
I have already updated that behavior with latest commit. Now we don't have persistent fallback for host variable. |
|
As far as I can tell from this PR, the following is not being done correctly:
BTW. Test coverage is looking good :) |
I am setting it explicitly on AblyRealtime constructor. https://github.com/ably/ably-java/pull/80/files#diff-b8b1ac0a34230df724c2576f32005521R54
Done, gokhanbarisaker@9ede727
Done, gokhanbarisaker@b21c73c
Done, gokhanbarisaker@55746eb
Done, gokhanbarisaker@0fcb999
Done, gokhanbarisaker@9e07f45
Done, gokhanbarisaker@5e8a523 |
| super(options); | ||
| channels = new Channels(); | ||
| connection = new Connection(this); | ||
| http.setHost(options.realtimeHost); |
There was a problem hiding this comment.
You're missing the point. The host that you happen to be connected to will change from time to time, because the fallback hosts behaviour applies to realtime connections, not just rest requests. So it won't work to freeze the realtime host here for the lifetime of the library.
There was a problem hiding this comment.
I solved that issue here https://github.com/ably/ably-java/pull/80/files#diff-060685a947a7032665de7ac9d33bb6ffR588
There was a problem hiding this comment.
I see two problems with this approach:
- You are setting the REST Host to the RealtimeHost in all situations. This is wrong, we only use the fallback host for REST requests when the realtime host is using that fallback host.
- If a realtime request falls back to a fallback host, but then later resumes using the default realtime host, all future REST requests will continue to go to the incorrect fallback host, see https://github.com/ably/ably-java/pull/80/files#diff-060685a947a7032665de7ac9d33bb6ffR588
See #80 (comment) |
| opts.port = testVars.port; | ||
| opts.tlsPort = testVars.tlsPort; | ||
| opts.tls = testVars.tls; | ||
| opts.httpMaxRetryCount = testVars.httpMaxRetryCount; |
There was a problem hiding this comment.
All of these httpMaxRetryCount configurations are still here and not related to the test in hand at all? Why can't they simply use the default?
|
@gokhanbarisaker I've added a few more comments... |
Done, gokhanbarisaker@d196d3f
Absolutely. Done, gokhanbarisaker@af2b5fb
Done, gokhanbarisaker@25cf247
Done, gokhanbarisaker@1c6e9c2 Also, I have updated the fallback handling behavior.
Done, gokhanbarisaker@fbba8db |
| ClientOptions opts = new ClientOptions(testVars.keys[0].keyStr); | ||
| opts.restHost = "some.other.host"; | ||
| ably = new AblyRealtime(opts); | ||
| assertEquals("Unexpected host mismatch", Defaults.getHost(opts), opts.restHost); |
There was a problem hiding this comment.
Why is this removed? I am assuming you want to configure realtimeHost and ensure it is used, but perhaps check that restHost remains unchanged, then change both and ensure both are used?
There was a problem hiding this comment.
AblyRealtime is using Http#setHost https://github.com/ably/ably-java/pull/80/files#diff-8a8a56ece4e68a2d0fbeb6639c2e5469R136
There was a problem hiding this comment.
So this worries me on two counts. Firstly, if you ave a test without an assertion, this is not a test. Secondly, this is a realtime test which is supposed to test that when the REST host is set, all rest requests go to that host. Equally, if a realtimeHost is set, then all realtime requests go to that host. We need that test as I am not confident that is working without suitable test coverage.
Resolves: #54, #14